<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>猜数字</title>
</head>
<body>
<input type="number" placeholder="请输入0-100之间的整数" id="i1">
<input type="button" value="猜一猜" onclick="f()">
<div>结果:<span></span>
</div>
<script>
  let x = parseInt(Math.random()*101);
  let num = 0;
  function f(){
    num++;
    let i1 = document.querySelector("#i1");
    let s = document.querySelector("span");
    if (i1.value > x)
      s.innerText = "猜大了小辣鸡 继续猜";
    else if (i1.value < x)
      s.innerText = "猜小了小辣鸡 继续猜";
    else
        s.innerText = "猜了" + num + "次,可以的鸭";
  }
</script>
</body>
</html>